package org.lsy.utils;

import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;

/**
 * @author liusy95
 * @version 1.0
 * @date 2020/7/2
 */
public class ContextUtils {

    private static AnnotationConfigApplicationContext context;

    public static void init() {
        context = new AnnotationConfigApplicationContext(ConsumerConfiguration.class);
        context.start();
    }

    public static AnnotationConfigApplicationContext getInstance() {
        return context;
    }

    @Configuration
    @PropertySource("classpath:/dubbo-consumer.properties")
    @ComponentScan(basePackages = "org.lsy.component")
    @EnableDubbo
    static class ConsumerConfiguration {
    }
}
